package com.right.health.app.ui.medical.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.magic.basic.adapter.BaseAbsAdapter;
import com.magic.basic.utils.TimeUtil;
import com.right.health.app.R;
import com.right.health.app.bean.SurgeryResponse;
import com.right.health.app.constants.AppConfig;


public class SurgeryListAdapter extends BaseAbsAdapter<SurgeryResponse.SurgeryInfo> {

    public SurgeryListAdapter(Context context) {
        super(context);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder = null;
        if(convertView == null) {
            convertView = mInflater.inflate(R.layout.surgery_list_item, null);
            viewHolder = new ViewHolder();

            viewHolder.nameTv = (TextView) convertView.findViewById(R.id.tv_name);
            viewHolder.timeTv = (TextView) convertView.findViewById(R.id.tv_time);
            viewHolder.descTv = (TextView) convertView.findViewById(R.id.tv_desc);

            convertView.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        SurgeryResponse.SurgeryInfo info = mDataSource.get(position);

        viewHolder.timeTv.setText(TimeUtil.convertTime(AppConfig.FORMAT_TIME, Long.parseLong(info.operationtime)));
//        viewHolder.timeTv.setText(info.operationtime);
        viewHolder.nameTv.setText(info.operationname);
        viewHolder.descTv.setText(info.operationdesc);
        return convertView;
    }

    private class ViewHolder {
        private TextView nameTv, timeTv, descTv;
    }
}
